Sub Main ()
with metascript 
   
   .showform "Select 0 as s, Code, Name, BillNo, BillDate , Payrupees, BillNo from salehead as h , customer as c , GIRN_Out as O " & _
      "  where customerkey = customerid and billno=docno and o.IRN<>''  and billdate between '" & local.dtfrom.tag & "' and '" & local.dtto.tag & "'" & _
      " ", .getdatafile, s1, s2,true
   
   if trim(s1)<>"" then 
      
      CnlRsn = inputbox ("Why Do you want to Cancel? Reason" & vbcrlf & "1. Duplicate" & vbcrlf & "2. Data Entry Mistake" & vbcrlf & "3. Order Cancel" & vbcrlf & "4. Others" & vbcrlf & "Please enter Reason Number:", "2")
      
      CnlRem = inputbox ("Why Do you want to Cancel? Description",  "Describe Reason ", "Incorrect Values")
      
      st = "insert into cirn_inp(DOCNO, DocDt, SLRGSTIN, Irn, CnlRsn, CnlRem)"
      st = st & " select DocNo, DocDt, SlrGSTIN, Irn, " & cnlrsn & ", " & CnlRem & " from GIrn_Out where docno in (" & s1 & ")" 
      
      if msgbox("Cancel selected Invoices? ", vbquestion + vbyesno,"Confirm") = vbyes then
         .exec "Update Salehead set GetIRN=0 where salekey in ("   & s1 & ")", .getdatafile
         .exec st & "", .getdatafile
         
         msgbox "Unmarking Done",vbinformation,"PharmaPulse"
         exit sub
      end if
   end if
   
   msgbox "Operation cancelled by user"
   
end with 
End Sub






